package com.cn.项目.飞机预约管理系统.Maininterface;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class UserManagement extends JPanel implements ActionListener {
    JPanel p3 = null;
    public UserManagement(){

        JPanel p1 = new JPanel();
        p1.setLayout(new BorderLayout());
        JPanel p2 = new JPanel();
        p2.setLayout(new GridLayout(1, 4));
        JButton jButton = new JButton("增加用户");
        jButton.addActionListener(this);
        p2.add(jButton);

        JButton jButton1 = new JButton("删除用户");
        jButton1.addActionListener(this);
        p2.add(jButton1);

        JButton jButton2 = new JButton("修改用户");
        jButton2.addActionListener(this);
        p2.add(jButton2);

        JButton jButton3 = new JButton("查找用户");
        jButton3.addActionListener(this);
        p2.add(jButton3);


        p1.add(p2,"North");
        p3  = new JPanel();

        p1.add(p3,"Center");


        this.add(p1);
        this.setVisible(true);
    }


    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand()=="增加用户"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new Addusers());
            p3.setVisible(true);
        }

        if (e.getActionCommand()=="删除用户"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new DeleteUsers());
            p3.setVisible(true);
        }

        if (e.getActionCommand()=="修改用户"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new UpdateUsers());
            p3.setVisible(true);
        }
        if (e.getActionCommand()=="查找用户"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new ShowUsers());
            p3.setVisible(true);
        }
    }
}
